package org.objective.base;

import java.util.UUID;
import org.objective.base.annotations.SystemField;
import org.objective.base.annotations.SystemFields;
import org.objective.ddl.type.DataType;

/**
 *
 * @author gus
 */
@SystemFields(fields =
{
    @SystemField(fieldName = "modified", type = DataType.DateTime)
})
public abstract class BaseDomainObject implements DomainObject, NameIdentified
{
    protected Storage storage;
    protected long id;
    protected UUID uid;  // TODO use EmptyUUID

    protected BaseDomainObject(Storage storage, long id)
    {
        this.id = id;
        this.storage = storage;
        uid = getUnique();
    }

    protected UUID getUnique()
    {
        return UUID.randomUUID();
    }

    @Override
    public long getID()
    {
        return id;
    }

    @Override
    public Storage getStorage()
    {
        return storage;
    }

    @Override
    public UUID getUID()
    {
        return uid;
    }

    public boolean isReadOnly()
    {
        return false;
    }

    public boolean needTable()
    {
        return false;
    }
}
    